/*
    15.Write a program in C to read a sentence and replace lowercase characters by uppercase and vice-versa. 

    Test Data :
    Input the string : This Is A Test String.

    Expected Output :

    The given sentence is   : This Is A Test String.
    After Case changed the string  is: tHIS iS a tEST sTRING.
*/

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#define MAX_STR 1024

char* getstr(char *str)
{
    char ch;
    char *p = str;
    while((ch = getchar()) != '\n'){
        *p = ch;
        p++;
    }
    *p = '\0';
    return str;
}

void versa(char *str)
{
    while(*str != '\0'){
        if(islower(*str)){
            *str = *str - 32;
        }else if(isupper(*str)){
            *str = *str + 32;
        }
        str++;
    }
}


int main(void)
{
    char *str = malloc(MAX_STR);
    printf("Input the string : ");
    getstr(str);
    printf("The given sentence is : %s\n", str);
    versa(str);
    printf("After Case changed the string is : %s", str);

    return 0;
}